home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / bipl.zip / PROGS.ZIP / SHAR.ICN < prev    next >
Text File  |  1992-09-28  |  2KB  |  59 lines

  1. ############################################################################
  2. #
  3. #    File:     shar.icn
  4. #
  5. #    Subject:  Program to crate shell archive UNIX
  6. #
  7. #    Author:   Robert J. Alexander
  8. #
  9. #    Date:     May 6, 1992
  10. #
  11. ###########################################################################
  12. #
  13. #  Program to create Bourne shell archive of text files.
  14. #
  15. #  Usage: shar text_file...
  16. #
  17. ############################################################################
  18.  
  19. procedure main(arg)
  20.    local fn, chars, f, line
  21.  
  22.    write(
  23.       "#! /bin/sh_
  24.      \n# This is a shell archive, meaning:_
  25.      \n# 1. Remove everything above the #! /bin/sh line._
  26.      \n# 2. Save the resulting text in a file._
  27.      \n# 3. Execute the file with /bin/sh (not csh) to create:")
  28.    every write("#\t",!arg)
  29.    write(
  30.       "# This archive created: ",&dateline,
  31.        "\nexport PATH; PATH=/bin:/usr/bin:$PATH")
  32.    every fn := !arg do {
  33.       chars := 0
  34.       f := open(fn) | stop("Can't open \",fn,"\"")
  35.       write(
  36.          "if test -f '",fn,"'_
  37.         \nthen_
  38.         \n\techo shar: \"will not over-write existing file '",fn,"'\"_
  39.         \nelse_
  40.         \ncat << \\SHAR_EOF > '",fn,"'")
  41.       while line := read(f) do {
  42.      write(line)
  43.      chars +:= *line + 1
  44.      }
  45.       write(
  46.         "SHAR_EOF_
  47.         \nif test ",chars," -ne \"`wc -c < '",fn,"'`\"_
  48.         \nthen_
  49.         \n\techo shar: \"error transmitting '",fn,"'\" '(should have been ",
  50.           chars," characters)'_
  51.         \nfi_
  52.         \nfi")
  53.       close(f)
  54.       }
  55.    write(
  56.       "exit 0_
  57.      \n#\tEnd of shell archive")
  58. end
  59.